<?php
include_once("config.php");
if (isset($_SESSION['adminName'])){
	$isAdmin=true;
}else{
	$isAdmin=false;
}
if ($isAdmin){
	if (isset($_POST['restuarantaddress'])){
		$isInputValid=true;
		$restuarantaddress=mysql_real_escape_string(stripcslashes($_POST['restuarantaddress']));
	}else{
		$isInputValid=false;
	}
}else{
	header("location: adminIndex.php");
}
if ($isInputValid){
	$query="SELECT * FROM restaurant WHERE address='$restuarantaddress'";
  $result1=mysql_query($query);
  $row=mysql_num_rows($result1);
  if ($row==1){
  	$canDelete=true;
  }
  else{
  	$canDelete=false;
  }
}else{
	echo "no such restuarant!";
	$canDelete=false;
}
if ($canDelete){
	$queryStr="DELETE FROM restaurant WHERE address='$restuarantaddress'";
	mysql_query($queryStr) or die("Cannot delete restuarant: ".mysql_error());
	header("location: viewrestuarant.php");
}else{
	" the restuarant cannot be deleted";
}
?>
